<?php
/*
 * get_comments( $args );
 *
 *
 *
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * CREATE USER 'meile'@'%';

GRANT SELECT ON * . *
TO  'meile'@'%'
WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0 ;
 */



	include "babs.php";
	dbtest();

	function tst32(){
			$testdb=pdbopen('localhost:3307','cultuuradm','test','cultuurdb');
		$fields=pdbqueryfields();
		pdbclose($testdb);
		//$fields=array_slice($fields,0,5);
		foreach ($fields as $f){
			echo $f[0] . '= ' . $_POST[$f[0]] . $CRLF;
		}
	}

	function dbtest(){
		global $CRLF;
		$testdb=pdbopen('localhost:3307','cultuuradm','test','cultuurdb');
		$t=pdbquery("SELECT * FROM `event` LIMIT 0, 30 ");
		$f=pdbqueryfields();
		pdbclose($testdb);

		$test=array();
		foreach  ($f as $f0) { echo  ptable($f0); }


		$form=array();
		foreach ($f as $field) {
			$label=$field[0];
			//$arr = preg_split('/\s*\\[|\\]\s*/',$input);
			$sqltype=preg_split('/\(.*?\)/',$field[1]);
			switch($sqltype[0]){
			case 'int':
				$type='text';
				break;
			case 'enum':
				$type='checkbox';
				break;
			default: $type='text';
			}
			$form[]=$CRLF;
			$form[]=$label;
			$form[]=pinput($field[0],$type);
			//echo $CRLF;
		}

		$form[]=$CRLF;
		$form[]=pinput($field[0],'submit');
		$form[]=pinput($field[0],'button','Cancel');
		echo pform(ptable($form));
		echo ptable($t); //HTML table
	}
?>